// 五行数据
export const WUXING = {
  JIN: '金',
  MU: '木',
  SHUI: '水',
  HUO: '火',
  TU: '土'
} as const;

// 生肖数据
export const ZODIAC = {
  RAT: '鼠',
  OX: '牛',
  TIGER: '虎',
  RABBIT: '兔',
  DRAGON: '龙',
  SNAKE: '蛇',
  HORSE: '马',
  GOAT: '羊',
  MONKEY: '猴',
  ROOSTER: '鸡',
  DOG: '狗',
  PIG: '猪'
} as const;

// 时辰数据
export const TIME_PERIODS = [
  { name: '子时', time: '23:00-01:00', element: WUXING.SHUI },
  { name: '丑时', time: '01:00-03:00', element: WUXING.TU },
  { name: '寅时', time: '03:00-05:00', element: WUXING.MU },
  { name: '卯时', time: '05:00-07:00', element: WUXING.MU },
  { name: '辰时', time: '07:00-09:00', element: WUXING.TU },
  { name: '巳时', time: '09:00-11:00', element: WUXING.HUO },
  { name: '午时', time: '11:00-13:00', element: WUXING.HUO },
  { name: '未时', time: '13:00-15:00', element: WUXING.TU },
  { name: '申时', time: '15:00-17:00', element: WUXING.JIN },
  { name: '酉时', time: '17:00-19:00', element: WUXING.JIN },
  { name: '戌时', time: '19:00-21:00', element: WUXING.TU },
  { name: '亥时', time: '21:00-23:00', element: WUXING.SHUI }
];

// 根据年份获取生肖
export function getZodiacByYear(year: number): string {
  const zodiacList = Object.values(ZODIAC);
  return zodiacList[(year - 4) % 12];
}

// 根据年月日计算五行
export function calculateWuxing(year: number, month: number, day: number): string {
  // 简化的五行计算，实际应该使用更复杂的算法
  const sum = year + month + day;
  const elements = ['金', '木', '水', '火', '土'];
  return elements[sum % 5];
}

// 根据时辰获取五行
export function getWuxingByTime(timePeriod: string): string {
  const period = TIME_PERIODS.find(p => p.name === timePeriod);
  return period ? period.element : WUXING.TU;
}

// 五行相生关系
export const WUXING_RELATIONS = {
  [WUXING.MU]: WUXING.HUO,  // 木生火
  [WUXING.HUO]: WUXING.TU,  // 火生土
  [WUXING.TU]: WUXING.JIN,  // 土生金
  [WUXING.JIN]: WUXING.SHUI, // 金生水
  [WUXING.SHUI]: WUXING.MU   // 水生木
};

// 五行相克关系
export const WUXING_CONFLICTS = {
  [WUXING.MU]: WUXING.TU,   // 木克土
  [WUXING.TU]: WUXING.SHUI, // 土克水
  [WUXING.SHUI]: WUXING.HUO, // 水克火
  [WUXING.HUO]: WUXING.JIN,  // 火克金
  [WUXING.JIN]: WUXING.MU    // 金克木
}; 